<template>
  <page-header-wrapper title="抽奖用户管理">
    <a-card title="编号管理">
      <s-table
        bordered
        ref="table"
        size="middle"
        :row-key="(record) => record.id"
        :columns="noColumns"
        :data="noData"
      >
        <template slot="no" slot-scope="text">
          <a-tag color="red">{{text}}</a-tag>
        </template>
        <template slot="is_luck" slot-scope="text">
          <a-tag color="red" v-if="text == 1">中奖</a-tag>
          <a-tag color="blue" v-else>未中奖</a-tag>
        </template>
        <template slot="action">
          <a-button size="small" type="danger" icon="delete">删除</a-button>
        </template>
      </s-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
  import { STable } from '@/components'
  import { getUserList } from '@/api/member'

  export default {
    components: {
      STable
    },
    name: 'MemberList',
    data () {
      return {
        noColumns: [
          {
            title: '编号',
            dataIndex: 'num',
            scopedSlots: { customRender: 'no' }
          },
          {
            title: '是否中奖',
            dataIndex: 'is_win',
            scopedSlots: { customRender: 'is_luck' },
            filterMultiple: false,
            onFilter: (value, record) => record.is_win.indexOf(value) === 0,
            filters: [
              {
                text: '中奖',
                value: '1'
              },
              {
                text: '未中奖',
                value: '0'
              }
            ]
          },
          {
            title: '操作',
            dataIndex: 'action',
            scopedSlots: { customRender: 'action' }
          }
        ],
        noData: parameters => {
          return getUserList(Object.assign(parameters, this.queryParam)).then(res => {
            return res.result
          })
        },
        queryParam: {}
      }
    },
    methods: {}
  }
</script>

<style scoped>

</style>
